package sun.springboot.mqtt_integration.core.messageHandle;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.MessageHandler;


/**
 * 主题信息监听
 */
@Configuration
public class InboundDataHandle {
    /*主题筛选对象*/
    private AbsTopicScreenDetails absTopicScreenDetails;


    public InboundDataHandle(AbsTopicScreenDetails absTopicScreenDetails) {
        this.absTopicScreenDetails = absTopicScreenDetails;
    }

    /**
     * 接受主题队列信息
     */
    @Bean
    @ServiceActivator(inputChannel = "mqttInputChannel")
    public MessageHandler handler() {
        return message -> absTopicScreenDetails.setMessage(message).screenTopic();
    }
}
